<?php

/**
 * $Id: base.php 12 2010-11-28 20:02:53Z LEON $
 * $Author: LEON $
 * $LastChangedDate: 2010-11-28 20:02:53 +0000 (Sun, 28 Nov 2010) $
 * $Revision: 12 $
 */

namespace cmFly\system\data_model;

abstract class base {

    /**
     *
     * @var \cmFly\system\context
     */
    private $context;
    
    public function __construct() {
	if(!$this->context = \cmFly::get_context()) {
	    throw new \cmFly\system\exceptions\fatal('Context is null! You do not running code from the cmFly context ?');
	}
    }

    protected function error($error_string, $error_num=0) {
	throw new exception($error_string, $error_num);
    }

    protected function get_context() {
	return $this->context;
    }
    /**
     *
     * @param string $to
     * @return \cmFly\db\PDO
     */
    public function get_database($to='default') {
	return $this->get_context()->get_database($to);
    }

    public function get_config() {
	return $this->get_context()->get_config();
    }
}